 		var account=  function () {
 				var qs =  new QueryString();
 				var tempAccount= qs.get("customerAccount");
 				if (!tempAccount) {
 					tempAccount = getManagerUser().Account;
 				}
 				return tempAccount;
 			};

		Ext.onReady(function(){
 			

			Ext.QuickTips.init();
 
			var proxy = new Ext.data.HttpProxy({
				api:{
					create: '/ad/sys/com/control/publish/PayToUserService.php?action=create&managerAccount='+account(),
					read:   '/ad/sys/com/control/publish/PayToUserService.php?action=read&managerAccount='+account(),
					update: '/ad/sys/com/control/publish/PayToUserService.php?action=update&managerAccount='+account(),
					destroy:'/ad/sys/com/control/publish/PayToUserService.php?action=destroy&managerAccount='+account() 
				}
			});
			
			var checkRenderer = function(value){
				if(value == 'M'){
					return '<input type="checkbox"/>';
				}else{
					return '<input type="checkbox"/>';
				}
			};
 
			var epaperRenderer = function(value){
				if(value){
					return '<span class="checked_span">&nbsp;</span>';
				}else{
					return '<span class="unchecked_span">&nbsp;</span>';
				}
			};
 
			//Various editors for the related fields:
			var textFieldEditor = {
				xtype:'textfield',
				allowBlank:false, blankText:'此欄不可空白',
				minLength:2, minText:'最少要填入{0}個字元',
				maxLength:20, maxText:'最多只能填入{0}個字元',regex:/[0-9]/
			};
			
			var genderFieldEditor = {
				xtype:'combo',
				triggerAction:'all',
				forceSelection:true,
				displayField:'label',
				valueField:'id',
				mode:'local',
				store:{
					xtype:'jsonstore',
					fields:[
						'id', 'label'
					],
					data:[
					   { id:'M', label:'男'  },
					   { id:'F', label:'女'  }
					]
				}
			};
			
			var dobFieldEditor = {
				xtype:'datefield',
				allowBlank:false, blankText:'此欄不可空白',
				editable:false
			};
			
			var epaperFieldEditor = {
				xtype:'checkbox'
			};
 
			//column definition
			var columns = [
			    { name:'PayId',   dataIndex:'PayId',   header:'付款編號', type:'string',  sortable:true, width:80, editor:false },
			    { name:'PayMoney', dataIndex:'PayMoney', header:'給付金額', type:'string',  sortable:true, width:50, editor:textFieldEditor },
			    { name:'PayDate',    dataIndex:'PayDate',    header:'給付日期', type:'date',    sortable:true, width:80, editor:dobFieldEditor,    renderer:Ext.util.Format.dateRenderer('Y年m月d日')},
			    { name:'Status',    dataIndex:'Status',header:'確認', type:'boolean',    sortable:false, width:80,   editor:false,  renderer:checkRenderer}
			];			
			
			var grid = new Aitch.ext.ETable({
//				store: new Ext.data.JsonStore ({
//				 		url : "/ad/sys/com/control/publish/UserService.php?action=queryAllPayToUserDateByAccount&managerAccount="+account(),
//						root : "row", 
//						remoteSort: false,
//						totalProperty: 'count',
//						fields : ["PayId", "PayMoney", "PayDate","Statue"]
//				}),
//		 		url:"/ad/sys/com/control/publish/UserService.php?action=queryAllPayToUserDateByAccount&managerAccount=koko0809@gmail.com",
				columns:columns,
				root:"row",
				gridPanelTitle : '付款資訊',
				gridPanelWidth:'100%',
				gridPanelHeight:280,
				pageSize:5,
				enableRowEditor:false,
				api:{
					create: '/ad/sys/com/control/publish/PayToUserService.php?action=create&managerAccount='+account(),
					read:   '/ad/sys/com/control/publish/PayToUserService.php?action=read&managerAccount='+account(),
					update: '/ad/sys/com/control/publish/PayToUserService.php?action=update&managerAccount='+account(),
					destroy:'/ad/sys/com/control/publish/PayToUserService.php?action=destroy&managerAccount='+account() 
				}
			});
			
			grid.renderPanel();	
			
			Ext.fly("search").on("click",function(){
				grid.addRec();
				});
			
		});
  
 		
$(document).ready(
	function(){
		$("#managerAccount").val(account());
		$('input[type="text"]').each(
			function(){
				$(this).change(
					function(){
						$('#bankDateChange').val('true');
					}
				);
			}
		);
		$('#changeDateCheck').click(
			function(){
				if($('#bankDateChange').val()=='true'){
					if(!confirm("已修改銀行資料，確定送出嗎？"))
					{
					    return;
					}
					
					$('form')[0].submit();
				}
			}	
		);
		
		
	}
);
 